import copy


def recognizer(code):
    outList = []

    import re
    #用正则表达式识别标识符
    pattern = r'[a-z,A-Z,_]+([a-z,A-Z,_,0-9])?|-?\d+(\.\d+)?|[+,-,*,/,>,<,=,{,},(,),\,,;]'   
    # [a-z,A-Z,_]+([a-z,A-Z,_,0-9])?:识别变量名
    # -?\d+(\.\d+)?:识别整数和浮点数
    # [+,-,*,/,=]:识别运算符
    for match in re.finditer(pattern, code):
        if not match.group() in outList:
            # outList.append(match.group())
            outList.append({"word": match.group(), "type": "UNKNOWN"})
    return outList

if __name__ == '__main__':
    code = "int var1; float var2;var1=5;var2=7.8;float c=var1*var2;"
    print(code)

    ids = recognizer(code)
    print(ids)
